package com.colin.aiyi.dao.ImpxUtils3_de;

import com.colin.aiyi.app.Constant;

import org.greenrobot.eventbus.EventBus;
import org.xutils.common.util.KeyValue;
import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by hl on 2017/5/24.
 */
@Deprecated
public    class AbsServicexUtils<T> extends AbsService<T> implements org.xutils.common.Callback.CommonCallback<String>{

    public int requestType;

    public  <E > void sendMsgToView(E e){
        EventBus.getDefault().post(e);
    }
    public void sendToServer(RequestParams params){
        sendToServer(params,0);
    }
    public void sendToServer(RequestParams params,int post){
        if (post==1)
        {
            x.http().post(params,this);
        }else {
            x.http().get(params,this);
        }

        if (Constant.debug)
        {
            System.out.println("请求地址："+params.getUri());
            for (KeyValue keyValue : params.getQueryStringParams()) {
                System.out.println("请求参数"+keyValue.key+":"+keyValue.getValueStr());
            }
            for (KeyValue keyValue : params.getBodyParams()) {
                System.out.println("请求参数"+keyValue.key+":"+keyValue.getValueStr());
            }

        }

    }

    @Override
    public void onSuccess(String result) {
        if (Constant.debug)
            System.out.println("返回结果"+result);
    }

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
//        callback.onSuccess(ex);
    }

    @Override
    public void onCancelled(CancelledException cex) {

    }

    @Override
    public void onFinished() {

    }

}
